package com.hang.jvm.risc;

import java.math.BigInteger;
import java.util.Arrays;

/**
 * @Author: LiaoJinghang
 * @CreateTime: 2023-02-08  14:09
 * @Description: RISC-V 32个通用寄存器
 * @Version: 1.0
 */
public class RegisterFile2 {
    private final BigInteger[] registers;

    public RegisterFile2() {
        registers = new BigInteger[32];
        Arrays.fill(registers, BigInteger.ZERO);
    }

    public BigInteger read(int index) {
        return registers[index];
    }

    public void write(int index, BigInteger value) {
        if (index != 0) {
            registers[index] = value;
        }

    }
}
